344. Reverse String
Description
Write a function that reverses a string. The input string is given as an array of characters s
.
You must do this by modifying the input array in-place with O(1)
extra memory.
참고
You can read the full description here.
Solution 1
Approach
- Use
list.reverse()
.
Implementation
class Solution:
def reverseString(self, s: List[str]) -> None:
s.reverse()
Complexity Analysis
- : length of
s
- Time Complexity:
- Space Complexity: